package cn.rongdao.jrkabao.model;

import com.mifengkong.frtools.http.request.HttpFunction;
import com.mifengkong.frtools.http.request.callback.FRBaseObserver;
import com.mifengkong.frtools.util.FRSharedPreferences;

import cn.rongdao.jrkabao.constant.SPConstant;
import cn.rongdao.jrkabao.model.api.BaseSuDaiModel;
import io.reactivex.Observable;
import io.reactivex.Observer;

/**
 * Created by jack on 17/5/11
 */

public class CustomerServiceModel extends BaseSuDaiModel {

    public static CustomerServiceModel getInstance() {
        return getPresent(CustomerServiceModel.class);
    }

    private void execute(Observer<String> observer) {
        addParamStrings("aap_type", "sudai");
        Observable<String> observable = mServletApi.getCustomerServiceTel(mParams).map(new HttpFunction<String>());
        toSubscribe(observable, observer);
    }

    public void setCustomService() {
        execute(new FRBaseObserver<String>() {
            @Override
            protected void onBaseNext(String data) {
                FRSharedPreferences.setStringNotClear(SPConstant.CUSTOMER_SERVICE, data);
            }

            @Override
            protected void onBaseError(Throwable t) {
                super.onBaseError(t);
            }
        });
    }
}
